package com.asia5b.a5mall.middleware.logic.viewmodel.member

import androidx.lifecycle.MutableLiveData
import com.asia5b.a5mall.middleware.base.SimpleViewModel
import com.asia5b.a5mall.middleware.model.member.CommentsModel
import com.asia5b.a5mall.middleware.model.shop.AbsShopModel
import io.reactivex.functions.Consumer

class CommentDetailActivityVM :SimpleViewModel() {

    var commentsModel: CommentsModel? = null
    /*
    http://47.88.223.5:4001/members/comments/608
    http://47.88.223.5:5000/member/my-comments/detail?comment_id=608
     */
    fun getCommentDetail(comment_id: Int) {
        val observable = memberApi.getCommentDetail("${comment_id}")
                .flatMap {
                    commentsModel = it
                    shopApi.getShop(it.seller_id)
                }
        baseSubscribe(observable, Consumer {
//            providerView().getCommentDetailResult(commentsModel)
            getCommentDetailResultLiveData.value=commentsModel
//            providerView().getShopResult(it!!)
            getShopResultLiveData.value=it!!
        })
    }

    val getCommentDetailResultLiveData=MutableLiveData<CommentsModel>()
    val getShopResultLiveData=MutableLiveData<AbsShopModel>()


}